﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualBasic;
using System.Runtime.InteropServices;

namespace kwzx
{
    class dwkey
    {
        public const short ORDER_OK = 0x30;
        public struct PChar
        {
            //UPGRADE_WARNING: 鍥哄畾闀垮害瀛楃涓茬殑澶у皬蹇呴』閫傚悎缂撳啿鍖恒€?鍗曞嚮浠ヨ幏寰楁洿澶氫俊鎭?鈥渕s-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="3C1E4426-0B80-443E-B943-0627CD55D48B"鈥?
            [VBFixedString(100), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst = 100)]
            public char[] MyGetData;
        }

        [DllImport("EHLKEY.DLL", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
        public static extern int TCPCONNECT(String ServerAddr);
        [DllImport("EHLKEY.DLL", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
        public static extern void TCPDISCONNECT();

        [DllImport("EHLKEY.DLL", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
        //KeyType类型          Gname宾客姓名,GID:,证件号      RoomName:房间名称         卡片有效期   KStart,  KEnd   CardID:返回的卡号
        public static extern int TCP_KEY(int KeyType, string GName, string GID, string RoomName, string KStart, string KEnd, ref int CardID);
        [DllImport("EHLKEY.DLL", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
        public static extern byte TCP_CHECKOUT(string RoomName, bool ClearCard);
        [DllImport("EHLKEY.DLL", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

        // public static extern byte TCP_CHECKCARD(ref byte KeyType, ref string GName, ref string GID, ref string RoomName, ref string KStart, ref string KEnd, ref int CardID);
        public static extern byte TCP_CHECKCARD(ref byte KeyType, ref PChar GName, ref PChar GID, ref PChar RoomName, ref PChar KStart, ref PChar KEnd, ref int CardID);

        //    Private Declare Function TCPCONNECT Lib "EHLKEY.DLL" (ByVal ServerAddr As String) As Byte
        //Private Declare Sub TCPDISCONNECT Lib "EHLKEY.DLL" ()
        //Private Declare Function TCP_KEY Lib "EHLKEY.DLL" (ByVal KeyType As Byte, ByVal GName As String, ByVal GID As String, ByVal RoomName As String, ByVal KStart As String, ByVal KEnd As String, CardID As Long) As Byte
        //Private Declare Function TCP_CHECKOUT Lib "EHLKEY.DLL" (ByVal RoomName As String, ByVal ClearCard As Boolean) As Byte
        //Private Declare Function TCP_CHECKCARD Lib "EHLKEY.DLL" (ByRef KeyType As Byte, _
        //                                                                                                        ByRef GName As PChar, _
        //                                                                                                        ByRef GID As PChar, _
        //                                                                                                        ByRef RoomName As PChar, _
        //                                                                                                        ByRef KStart As PChar, _
        //                                                                                                        ByRef KEnd As PChar, _
        //                                                                                                        ByRef CardID As Long) As Byte
    }
}
